// pages/subject/subject_info/subject.js
const api=require('../../../utils/request')
Page({

  /**
   * 页面的初始数据
   */
  data: {
     context:'',
     updateTime:'',
     name:'',
     tagName:'',
     reportResList:[],
     image:'',
     reportNum:'',
     twoArray:[]
  },
  downloadVip(){
    wx.showToast({
        title: '登录电脑端下载',
        icon: 'none',
        duration: 2000,
      })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log('options',options)
    const that=this
    api.get('weChatMini/findSpecialListById/'+options.id).then(response=>{
        
        if(response.code===200){
           const data= response.data
           let firstArray=[]
           let twoArray=[]
           let reportResList=data.reportResList
           if(reportResList!=null && reportResList.length>5){
            firstArray=reportResList.slice(0,3)
            twoArray=reportResList.slice(3)
           }

           that.setData({
               name:data.name,
               context:data.context,
               image:data.image,
               updateTime:data.updateTime,
               tagName:data.tagName,
               reportResList:firstArray,
               reportNum: data.reportResList.length,
               twoArray: twoArray
           })
        }
    }) 
  },
 showPdf(e) {
    let id= e.currentTarget.dataset.id
        wx.navigateTo({
            url:'../../report/pdf/pdf?id='+id+'&type=3'
          })
    
},
showPdf1(e) {
     
    let userInfo= wx.getStorageSync('user') 
    if(userInfo===''){
        wx.navigateTo({
            url: '../../login/login?type=1',
          })
    }else{
        let user= JSON.parse(userInfo)
        if(user.ruleId<4){
            wx.showToast({
                title: '升级高级会员或企业会员',
                icon: 'none',
                duration: 2000,
              })
              return false
        } 
        let id= e.currentTarget.dataset.id
        wx.navigateTo({
            url:'../../report/pdf/pdf?id='+id+'&backType=3'
          })
    }
    
},
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})